use std::collections::HashMap;
use tokio::sync::mpsc;
use uuid::Uuid;

use crate::websockt::WebSocketFrame;

pub struct WebSocketConnectionPool { 
    pub(crate) peers: HashMap<Uuid, mpsc::UnboundedSender<WebSocketFrame>>,
}

impl WebSocketConnectionPool {
    pub fn new() -> Self {
        Self {
            peers: HashMap::new()
        }
    }

    pub async fn register(&mut self, id: Uuid, tx: mpsc::UnboundedSender<WebSocketFrame>) {
        self.peers.insert(id, tx);
    }

    pub async fn unregister(&mut self, id: &Uuid) {
        self.peers.remove(id);
    }
}
